from datetime import datetime
import uuid
from pony import orm

from .config import settings

# orm.set_sql_debug(True)


db = orm.Database()
db.bind(
    provider='postgres',
    host=settings.PG_HOST_DW,
    port=settings.PG_PORT_DW,
    database=settings.PG_DATABASE_DW,
    user=settings.PG_USERNAME_DW,
    password=settings.PG_PASSWORD_DW,
)


def generate_uuid():
    return uuid.uuid4().hex

################
# place all entities below
################

# Required, 必须有值的字段, 值不能是null或者''
# Optional, 值可以为null或者''的字段, 字符字段默认为'', 其它字段默认为null

class Servicenhsa(db.Entity):
    _table_ = 'yaopin_yibaoju'

    id = orm.PrimaryKey(int)
    name = orm.Optional(str)



################
# place all entities above
################


# all entities connected to the database must be defined before calling generate_mapping()
# if the tables do not already exist, then they will be created
db.generate_mapping(create_tables=True)
# db.generate_mapping()
